/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.projectdarkstar.ai.tree.test;

import com.projectdarkstar.ai.tree.ParallelTreeNode;
import java.io.Serializable;

/**
 *
 * @author Jeff Kesselman
 */
public class ParallelWordJumbler implements ParallelTreeNode, Serializable {
    String word;
    String remainingLetters;
    
    public ParallelWordJumbler(String word, String remainingLetters){
 
        this.word = word;
        this.remainingLetters = remainingLetters;
    }

    public int childCount() {
       return remainingLetters.length();
    }

    public void childDone(ParallelTreeNode node) {
        // does nothing
    }

    public ParallelTreeNode[] children() {
        ParallelTreeNode[] children = new ParallelTreeNode[childCount()];
        for(int i=0;i<children.length;i++){
            children[i] = new ParallelWordJumbler(word+remainingLetters.charAt(i),
                    remainingLetters.substring(0, i)+
                    remainingLetters.substring(i+1));
        }
        return children;
    }

    public void postDescentEvaluate(boolean isRoot) {
        if (isRoot){
            System.out.println("done");
        }
    }

    public void preDescentEvaluate() {
        System.out.println(word);
    }
    
    
    
   
}
